void main() {
  Spacecraft("小飞棍", DateTime(1999, 3, 3)).describe();
  Spacecraft.unlaunched("大飞棍").describe();
}

/// 宇宙飞船
class Spacecraft {
  String name;
  DateTime launchDate;

  int get launchYear => launchDate.year;

  Spacecraft(this.name, this.launchDate) {}

  Spacecraft.unlaunched(name) : this(name, DateTime(0, 0, 0));

  void describe() {
    print('飞船名： $name');
    if (launchDate.year == 0) {
      // ~/ 取整
      var years = DateTime.now().difference(launchDate).inDays ~/ 365;
      print("启动于： $launchYear 年, 已运行：$years 年");
    } else {
      print("未启动");
    }
  }
}
